import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-03-13
 * Time: 0:23
 */
public class Main5 {
    public static void main(String[] args) {

        String password = "123456";

        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入密码：");

        int retrytime = 3;



        //3次

        for (int i = 0; i < 3; i++) {

            String input = scanner.nextLine();

            if (input.equals(password)) {

                System.out.println("输入正确！");

                break;

            }

            else {

                retrytime--;

                System.out.println("输入错误，请重新输入,还有" + retrytime + "次机会");

            }

        }

        //输入错误三次

        if (retrytime == 0) {

            System.out.println("输入次数用完，退出程序");

        }

    }


}
